package com.hqyj.module.index.dao;

import com.hqyj.module.index.pojo.DeptTime;
import com.hqyj.module.index.pojo.Honour;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lap
 * @version 1.0
 * @date 2021/10/8 16:29
 */
@Repository
public interface HonourDao {
    @Select("SELECT ui.user_name,ui.dept_name,COUNT(clock.money) as many\n" +
            "from user_info ui LEFT JOIN clock \n" +
            "ON ui.user_id = clock.user_id\n" +
            "WHERE clock.money is not null\n" +
            "GROUP BY clock.user_id \n" +
            "ORDER BY COUNT(clock.money) DESC\n" +
            "LIMIT 1")
    Honour getLate();

    @Select("SELECT ui.user_name,ui.dept_name,COUNT(clock.work_money) as many\n" +
            "from user_info ui LEFT JOIN clock \n" +
            "ON ui.user_id = clock.user_id\n" +
            "WHERE clock.work_money=0\n" +
            "GROUP BY clock.user_id\n" +
            "ORDER BY COUNT(clock.money) DESC\n" +
            "LIMIT 1")
    Honour getLeave();

    @Select("SELECT ui.user_name,ui.dept_name,COUNT(ho.user_id) as many\n" +
            "from user_info ui LEFT JOIN holiday ho \n" +
            "ON ui.user_id = ho.user_id\n" +
            "WHERE ho.ho_type = 'thing'\n" +
            "GROUP BY ho.user_id \n" +
            "ORDER BY COUNT(ho.user_id) DESC\n" +
            "LIMIT 1")
    Honour getThing();

    @Select("SELECT ui.user_name,ui.dept_name,COUNT(ho.user_id) as many\n" +
            "from user_info ui LEFT JOIN holiday ho \n" +
            "ON ui.user_id = ho.user_id\n" +
            "WHERE ho.ho_type = 'business'\n" +
            "GROUP BY ho.user_id \n" +
            "ORDER BY COUNT(ho.user_id) DESC\n" +
            "LIMIT 1")
    Honour getBusiness();


    @Select("SELECT ui.user_name,ui.dept_name,ui.lateandearly_num as many\n" +
            "from user_info ui\n" +
            "WHERE ui.lateandearly_num = 0")
    List<Honour> getLoadLateAndEarly();

    @Update("UPDATE user_info set leave_num = 5,lateandearly_num = 5")
    Integer updateTime();



}
